﻿@model article_hot
@{
    ViewData["Title"] = "热门文章链接详情页";
    var hot = Model;
}

<div class="row">
    <form id="ajaxForm" enctype="multipart/form-data" class="form-horizontal">
        <input type="hidden" name="id" value="@hot.id.ToString()" />
        <div class="container-fluid">
            <div class="row form-group">
                <label class="control-label col-md-2">标题</label>
                <div class="col-md-8">
                    <input class="form-control" name="title" id="title" type="text" value="@hot.title" />
                </div>
            </div>
            <div class="row form-group">
                <label class="control-label col-md-2">链接</label>
                <div class="col-md-8">
                    <input class="form-control" name="url" id="url" type="text" value="@hot.url" />
                </div>
            </div>
            <div class="row form-group">
                <label class="control-label col-md-2">排序</label>
                <div class="col-md-8">
                    <input class="form-control" name="sort_num" id="sort_num" type="text" value="@hot.sort_num" />
                </div>
            </div>
            <div class="row form-group">
                <label class="control-label col-md-2">修改人</label>
                <div class="col-md-8">
                    <input class="form-control" name="change_user_name" id="change_user_name" type="text" value="@hot.change_user_name" />
                </div>
            </div>
            <div class="row form-group">
                <label class="control-label col-md-2">创建时间</label>
                <div class="col-md-8">
                    <input class="form-control" name="create_time" id="create_time" type="text" value="@hot.create_time.ToLocalDateTimeString()" readonly />
                </div>
            </div>
            <div class="row form-group">
                <label class="control-label col-md-2">更新时间</label>
                <div class="col-md-8">
                    <input class="form-control" name="last_update" id="last_update" type="text" value="@hot.last_update.ToLocalDateTimeString()" readonly />
                </div>
            </div>

            <div class="row form-group">
                <div class="col-md-6 col-md-offset-1">
                    <button type="button" class="btn btn-primary" onclick="SaveResurt()">保存</button>
                </div>
            </div>
        </div>
    </form>
</div>

@section scripts{
    <script type="text/javascript">

        function SaveResurt() {
            if ($("#title").val().length == 0) {
                utils.ShowError("请输入标题");
                return;
            }
            if ($("#url").val().length == 0) {
                utils.ShowError("请输入链接");
                return;
            }
            if ($("#sort_num").val().length == 0 || isNaN(parseInt($("#sort_num").val()))) {
                utils.ShowError("请输入正确的排序数字");
                return;
            }

            $("#ajaxForm").ajaxSubmit({
                type: 'post',
                url: '@Url.Action("Update")',
                data: {

                },  // data是作为额外提交的表单数据
                success: function (e) {
                    if (e.msg == 'ok') {
                        utils.ShowSuccess(e.data, function () {
                            location.reload(true);
                        });
                    }
                },
                error: function (e) {
                    utils.ShowError(e.msg);
                }
            });
        }
    </script>
}

